[ExecuTorch][Vulkan] Add et_vk.q4gsw_requant kernel (STE re-quant to W_4X8)#20945
Open
JCNTH wants to merge 3 commits into
Open
[ExecuTorch][Vulkan] Add et_vk.q4gsw_requant kernel (STE re-quant to W_4X8)#20945JCNTH wants to merge 3 commits into
JCNTH wants to merge 3 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20945
Note: Links to docs will display an error until the docs builds have been completed. ❌ 10 New FailuresAs of commit 2895d46 with merge base 7013c8d ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Jul 14, 2026
Open
[ExecuTorch][WebGPU] Add et_vk.adamw_step (on-GPU AdamW optimizer step) to the WebGPU backend
#20935
Open
This was referenced Jul 14, 2026
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Adds the Vulkan
et_vk.q4gsw_requantkernel — straight-through re-quant of fp32 latent weights into the frozen-scale 4-bit codes, for on-device weight training. Writes the codes directly in the forward's W_4X8 layout so no per-step re-pack is needed.Problem:
et_vk.q4gsw_requantis registered in the shared Vulkan partitioner but Vulkan had no runtime kernel.Solution: a GLSL kernel that quantizes
round(latent / scale)clamped to[-8, 7]and packs the codes in the W_4X8 block layout the forward reads, reusing the exact byte-pair convention ofglsl/pack_q4_linear_weight__w_4x8.glsl(even-N low nibble, odd-N high; one ivec4 per 4K x 8N block at(k4, n8); OOB upper tile = the bias-zero0x88888888). A zero scale yields code 8 (no divide-by-zero), matching the eager reference.Key changes:
glsl/q4gsw_requant.{glsl,yaml}— buffer x float; 2D dispatch over(k4, n8).impl/QuantizedLinearRequant.cpp— prepacks the constant scales; output is the W_4X8 int buffer[K4 * N4_padded * 2];group_sizespec constant; dispatch-grid guard.Design note (for review): per the layout decision, requant writes W_4X8 to match the Vulkan forward. Today the forward and backward each prepack their own flat
[N, K/2]weight internally, so nothing yet consumes an externally-produced W_4X8 buffer — closing the training loop needs a forward path that reads a mutable pre-packed weight (the weight-lifecycle follow-up). The op's AOT meta incustom_ops_lib.pystill describes the flat[N, K/2]output and should be reconciled with this W_4X8 output.Constraints: buffer storage, fp32 latent/scales;
N % 4 == 0,K % 4 == 0,group_size % 4 == 0.@exported-using-ghexport
Differential Revision: D111797527
Differential Revision: D111797527